package Chapter7;
//145页程序7.3 对象存储到文件中

import java.io.*;

public class ObjectStorage implements Serializable { //storage存储
    public static void main(String[] args) {
        Student stu = new Student(981036,"Li Hua",22,"计算机系");
        try {
            FileOutputStream fo = new FileOutputStream("asd2.txt");
            ObjectOutputStream so = new ObjectOutputStream(fo);
            so.writeObject(stu);
            so.close();
            System.out.println("对象成功存入到asd2.txt文件中！");
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}
